<template>
    <Crud :table="table" :columns="columns" v-model:saveFormData="saveFormData" v-model:searchObj="searchObj">
        <template #save>
            <a-form
                ref="save_form"
                :model="saveFormData"
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
            >
                <a-form-item label="商户名称" name="name" :rules="[{ required: true, message: '' }]">
                    <a-input v-model:value="saveFormData.name"/>
                </a-form-item>
                <a-form-item label="手机" name="tel" :rules="[{ required: true, message: '' }]">
                    <a-input v-model:value="saveFormData.tel"/>
                </a-form-item>
                <a-form-item label="商户简介" name="title" :rules="[{ required: true, message: '' }]">
                  <a-input v-model:value="saveFormData.title"/>
                </a-form-item>
                <a-form-item label="开放时间" name="open_time" :rules="[{ required: true, message: '' }]">
                  <a-input v-model:value="saveFormData.open_time"/>
                </a-form-item>
                <a-form-item label="状态" name="status" :rules="[{ required: true, message: '' }]">
                    <Select placeholder="状态" v-model:value="saveFormData.status" :constant="constant.mch_status"/>
                </a-form-item>
                <a-form-item label="LOGO" name="logo_img" :rules="[{ required: true, message: '' }]">
                    <Upload :maxCount="1" v-model:value="saveFormData.logo_img"/>
                </a-form-item>
                <a-form-item label="设备照片" name="device_img" :rules="[{ required: true, message: '' }]">
                  <Upload :maxCount="5" v-model:value="saveFormData.device_img"/>
                </a-form-item>
                <a-form-item label="地址" name="address" :rules="[{ required: true, message: '' }]">
                    <MapSelect v-model:value="saveFormData"/>
                </a-form-item>
                <a-form-item label="服务" name="services" :rules="[{ required: true, message: '' }]">
                  <CheckBox v-model:value="saveFormData.services" :options="[{icon:'icon-reshui',name:'热水'},{icon:'icon-water',name:'冷水'},{icon:'icon-zhaocesuo',name:'WC'}]"/>
                </a-form-item>
                <a-form-item label="归属用户" name="user_id">
                  <RemoteSelect table="user" name_key="username" v-model:value="saveFormData.user_id"/>
                </a-form-item>

            </a-form>
        </template>
        <template #search>
            <a-form
                layout="inline"
            >
                <a-form-item>
                    <a-input placeholder="名称" v-model:value="searchObj.name"/>
                </a-form-item>
                <a-form-item>
                    <a-input placeholder="手机号" v-model:value="searchObj.tel"/>
                </a-form-item>
                <a-form-item>
                    <Select placeholder="状态" v-model:value="searchObj.status" :constant="constant.mch_status"/>
                </a-form-item>
            </a-form>
        </template>
    </Crud>
</template>

<script>

export default {
    name: "list",
    data: function () {
        return {
            table: 'mch',
            saveFormData: {
              user_id:0
            },
            searchObj: {},
            columns: [
                {
                    title: '商户名称',
                    key: 'name',
                },
                {
                    title: '状态',
                    key: 'status',
                    render: (record) => {
                        return this.constant.mch_status[record.status]
                    }
                },
                {
                    title: '手机',
                    key: 'tel',
                },
                // {
                //     title: '用户名',
                //     key: 'username',
                // },
                {
                    title: 'LOGO',
                    key: 'logo_img',
                }, {
                    title: '添加时间',
                    key: 'add_time',
                },
            ],
        };
    },
    computed: {
        table_key() {
            return `${this.table}_id`
        },
    },
    components: {},
    created() {
    },
    watch: {},
    methods: {}
}
</script>

<style scoped lang="less">

</style>